﻿#ifndef CAMERA_H
#define CAMERA_H

//#include "DxImageProc.h"
//#include "GxIAPI.h"
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <string>
#include <iostream>
#include <atlimage.h>
#include <math.h>
//#include <OMMSystem.h>
using namespace std;
using namespace cv;

class AsynGrab 
{
   public:
    AsynGrab();
    ~AsynGrab();
//    void  ShowImage(GX_FRAME_DATA *pFrameData);

    int init();
    // 设备初始化
   // GX_STATUS InitDevice();
    //----------------显示图像相关函数--------------------------
    bool                m_bColorFilter;
    bool                bColorFliter;
   // bool                m_bDevOpened;
//    GX_DEV_HANDLE       m_hDevice;              //< 设备句柄
    BYTE                *m_pBufferRaw;          //< 原始图像数据
    BYTE                *m_pBufferRGB;	        //< RGB图像数据，用于显示和保存bmp图像
    int                 m_nImageHeight;         //< 原始图像高
    int                 m_nImageWidth;          //< 原始图像宽
    int                 m_nPayLoadSize;
    int                 m_nPixelColorFilter;    //< Bayer格式
//    GX_FRAME_DATA       m_stFrameData;       //< GetImage获取的图像地址
	bool                isStreaming;
	//bool	m_bColorFilter;
	BITMAPINFO          *m_pBmpInfo;	        ///< BITMAPINFO 结构指针，显示图像时使用
	char                 m_chBmpBuf[2048];	    ///< BIMTAPINFO 存储缓冲区，m_pBmpInfo即指向此缓冲区
    int OpenDevice();
    int CloseDevice();
	IplImage *test;
    //void *pUserParam;
    //显式退出函数
    int shutDown();
//	static void __stdcall OnFrameCallbackFun(GX_FRAME_CALLBACK_PARAM* pFrame);
	//曝光设置
//	GX_STATUS SetExposure(double m_dShutterValue);
    protected:
      CImage *m_pImage ;
     // char *bgr24_bgr32(int width,int height, char *src);
     // void IplImageToQImage( IplImage *img);
      //QImage *mat2qimage(const Mat &mat);
    void CopyToImage( BYTE *m_changeImage, CImage *pOutImage );
	void GetHeight();
	void GetWidth();
public :
    void onStart();
	void onStop();

//signals:
  //  void imgReady(QImage *);

};
extern AsynGrab abc;


#endif // CAMERA_H
